package com.abe.bathsystem.contract.presenter;

import com.abe.bathsystem.contract.CommonContract;
import com.abe.bathsystem.contract.CommonModel;
import com.abe.bathsystem.entity.ReqBaseEntity;
import com.abe.bathsystem.entity.ReqConstant;
import com.abe.bathsystem.entity.http.HttpAdEntity;
import com.abe.bathsystem.entity.http.HttpNoticeEntity;
import com.abe.mvpcore.BasePresenter;
import com.abe.mvpcore.OnResultListener;

import java.util.List;

public class AdPresenter extends BasePresenter<CommonContract.AdView, CommonModel> implements CommonContract.AdPresenter {

    @Override
    public void getAdData() {
        getModel().getAdData(new OnResultListener<ReqBaseEntity<List<HttpAdEntity>>>() {
            @Override
            public void onStart() {

            }

            @Override
            public void onEnd() {
                AdPresenter.this.onEnd(AdPresenter.class.getSimpleName() + "-getAdData");
            }

            @Override
            public void onSuccess(ReqBaseEntity<List<HttpAdEntity>> data) {
                if (AdPresenter.this.onSuccess(data) && data.getCode() == ReqConstant.NET_RESULT_OK) {
                    getView().onAdData(data.getData());
                }
            }

            @Override
            public void onFailure(String message) {
                AdPresenter.this.onFailure(AdPresenter.class.getSimpleName() + "-getAdData");
            }
        });
    }

    @Override
    public void getNotice() {
        getModel().getNotice(new OnResultListener<ReqBaseEntity<List<HttpNoticeEntity>>>() {
            @Override
            public void onStart() {

            }

            @Override
            public void onEnd() {
                AdPresenter.this.onEnd(AdPresenter.class.getSimpleName() + "-getNotice");
            }

            @Override
            public void onSuccess(ReqBaseEntity<List<HttpNoticeEntity>> data) {
                if (AdPresenter.this.onSuccess(data) && data.getCode() == ReqConstant.NET_RESULT_OK) {
                    getView().onNoticeData(data.getData());
                }
            }

            @Override
            public void onFailure(String message) {
                AdPresenter.this.onFailure(AdPresenter.class.getSimpleName() + "-getNotice");
            }
        });
    }
}
